package com.geektime.hello.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: DRevelation
 * @Date: 2021/1/28 16:26
 */
@RestController
@RequestMapping("thread")
public class ThreadController {

    @GetMapping("start")
    public String start() {
        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                new Thread(() -> {
                    System.out.println(Thread.currentThread().getName()+ " start...");
                }, "Thread" + i).start();
            }
        }).start();
        return "start";
    }

}
